// Decompiled by JAD v1.5.4.2. Copyright 1997-98 Pavel Kouznetsov.
// JAD Home Page:      http://web.unicom.com.cy/~kpd/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   Zoop.java

import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;

public class Zoop extends Applet
{

    public void init()
    {
        getAppletContext().showStatus("Loading Zoop!");
        try
        {
            zd = new ZoopDisplay(this);
        }
        catch(Exception ex)
        {
            return;
        }
        requestFocus();
        ot = new OpponentThread(zd, this);
        ot.start();
        getAppletContext().showStatus("Zoop!");
        ot.setPriority(1);
    }

    public void stop()
    {
        if(ot != null && ot.isAlive())
            ot.stop();
        ot = null;
    }

    public void update(Graphics g)
    {
        paint(g);
    }

    public void paint(Graphics g)
    {
        try
        {
            zd.paint(g);
            return;
        }
        catch(NullPointerException ex)
        {
            return;
        }
    }

    public boolean mouseDown(Event event, int i, int j)
    {
        repaint();
        return true;
    }

    public boolean keyDown(Event event, int i)
    {
        switch(i)
        {
        case 32: /* ' ' */
            zd.fire();
            break;

        case 89: /* 'Y' */
        case 121: /* 'y' */
            zd.PromptKey(2);
            break;

        case 78: /* 'N' */
        case 110: /* 'n' */
            zd.PromptKey(1);
            break;

        case 74: /* 'J' */
        case 106: /* 'j' */
        case 1006: 
            zd.moveChomper((byte)0);
            break;

        case 76: /* 'L' */
        case 108: /* 'l' */
        case 1007: 
            zd.moveChomper((byte)2);
            break;

        case 73: /* 'I' */
        case 105: /* 'i' */
        case 1004: 
            zd.moveChomper((byte)1);
            break;

        case 75: /* 'K' */
        case 107: /* 'k' */
        case 1005: 
            zd.moveChomper((byte)3);
            break;

        }
        return true;
    }

    public Zoop()
    {
    }

    private static ZoopDisplay zd;
    private OpponentThread ot;
}
